package primary.linkedList;

/**
 * @Author Elephas
 * @Date 2022/1/8
 **/
public class DeleteNode {

    /*
        将node依次用node的next替代，删除尾元素,看了答案，自己没想出来
     */
    public void deleteNode(ListNode node){
        ListNode pre = node;
        ListNode cur = node.next;


        while(cur.next!=null){
            pre.val = cur.val;
            pre = cur;
            cur = cur.next;
        }
        pre.val = cur.val;
        pre.next = null;
        return;
    }
}

